/*
 * bsp_xzc_gy.c
 *
 *  Created on: Jul 26, 2022
 *      Author: kaijunHuang
 */



#include "main.h"
#include "bsp_xzc_gy.h"
#include "bsp_includes.h"

#if XZC_GY_MODULE_ENABLED

DataBuffer dataBuffer[DATABUFFERSIZE];
ErrorBuffer ErrorID[DATABUFFERSIZE];
short temperature = 0;
uint8_t serialNum = 0;
uint16_t communicationErrorFlag;
uint16_t receiveFlag = 0xFFFF;
float power = 0;
DataBuffer gaoYa1Data[UPLOADDATASIZE];

void DataInitForTest(void)
{
	//通讯
	communicationErrorFlag = 0x00;
	//温度
	temperature = 350;
	//发控电源1
	dataBuffer[0].data[1] = 0x00;
	dataBuffer[0].data[2] = 0x00;
	dataBuffer[0].data[3] = 0x00;
	dataBuffer[0].data[4] = 0x00;
	dataBuffer[0].data[5] = 0x00;
	dataBuffer[0].data[6] = 0x00;
	dataBuffer[0].data[7] = 0x03;
	//发控电源2
	dataBuffer[1].data[1] = 240;
	dataBuffer[1].data[2] = 0x00;
	dataBuffer[1].data[3] = 20;
	dataBuffer[1].data[4] = 0x00;
	dataBuffer[1].data[5] = 0x00;
	dataBuffer[1].data[6] = 0x01;
	dataBuffer[1].data[7] = 0x00;
	//发控电源3
	dataBuffer[2].data[1] = 240;
	dataBuffer[2].data[2] = 0x00;
	dataBuffer[2].data[3] = 20;
	dataBuffer[2].data[4] = 0x00;
	dataBuffer[2].data[5] = 0x00;
	dataBuffer[2].data[6] = 0x00;
	dataBuffer[2].data[7] = 0x00;
	//车调驱动1
	dataBuffer[3].data[1] = 240;
	dataBuffer[3].data[2] = 0x00;
	dataBuffer[3].data[3] = 20;
	dataBuffer[3].data[4] = 0x00;
	dataBuffer[3].data[5] = 0x00;
	dataBuffer[3].data[6] = 0x00;
	dataBuffer[3].data[7] = 0x00;
    //车调驱动2
	dataBuffer[4].data[1] = 0x18;
	dataBuffer[4].data[2] = 0x15;
	dataBuffer[4].data[3] = 20;
	dataBuffer[4].data[4] = 0x00;
	dataBuffer[4].data[5] = 0x00;
	dataBuffer[4].data[6] = 0x00;
	dataBuffer[4].data[7] = 0x00;
    //车调驱动3
	dataBuffer[5].data[1] = 0x18;
	dataBuffer[5].data[2] = 0x15;
	dataBuffer[5].data[3] = 20;
	dataBuffer[5].data[4] = 0x00;
	dataBuffer[5].data[5] = 0x00;
	dataBuffer[5].data[6] = 0x00;
	dataBuffer[5].data[7] = 0x00;
    //车调驱动4
	dataBuffer[6].data[1] = 0x18;
	dataBuffer[6].data[2] = 0x15;
	dataBuffer[6].data[3] = 20;
	dataBuffer[6].data[4] = 0x00;
	dataBuffer[6].data[5] = 0x00;
	dataBuffer[6].data[6] = 0x00;
	dataBuffer[6].data[7] = 0x00;
    //车调驱动5
	dataBuffer[7].data[1] = 0x18;
	dataBuffer[7].data[2] = 0x15;
	dataBuffer[7].data[3] = 20;
	dataBuffer[7].data[4] = 0x00;
	dataBuffer[7].data[5] = 0x00;
	dataBuffer[7].data[6] = 0x00;
	dataBuffer[7].data[7] = 0x00;
    //天线杆
	dataBuffer[8].data[1] = 0x18;
	dataBuffer[8].data[2] = 0x15;
	dataBuffer[8].data[3] = 20;
	dataBuffer[8].data[4] = 0x00;
	dataBuffer[8].data[5] = 0x00;
	dataBuffer[8].data[6] = 0x00;
	dataBuffer[8].data[7] = 0x00;
    //高压输入
	dataBuffer[9].data[1] = 0x18;
	dataBuffer[9].data[2] = 0x15;
	dataBuffer[9].data[3] = 20;
	dataBuffer[9].data[4] = 0x00;
	dataBuffer[9].data[5] = 0x00;
	dataBuffer[9].data[6] = 0x00;
	dataBuffer[9].data[7] = 0x00;
}
void Upload_To_Xiankong()
{
//	DataInitForTest();
	gaoYa1Data[0].data[0] = 0x1Au;
	gaoYa1Data[0].data[1] = serialNum++;
	gaoYa1Data[0].data[2] = dataBuffer[0].data[1];
	gaoYa1Data[0].data[3] = dataBuffer[0].data[2];
	gaoYa1Data[0].data[4] = dataBuffer[0].data[3];
	gaoYa1Data[0].data[5] = dataBuffer[0].data[4];
	gaoYa1Data[0].data[6] = dataBuffer[1].data[1];
	gaoYa1Data[0].data[7] = dataBuffer[1].data[2];

	gaoYa1Data[1].data[0] = 0x2Au;
	gaoYa1Data[1].data[1] = dataBuffer[1].data[3];
	gaoYa1Data[1].data[2] = dataBuffer[1].data[4];
	gaoYa1Data[1].data[3] = dataBuffer[2].data[1];
	gaoYa1Data[1].data[4] = dataBuffer[2].data[2];
	gaoYa1Data[1].data[5] = dataBuffer[2].data[3];
	gaoYa1Data[1].data[6] = dataBuffer[2].data[4];
	gaoYa1Data[1].data[7] = dataBuffer[3].data[1];

	gaoYa1Data[2].data[0] = 0x3Au;
	gaoYa1Data[2].data[1] = dataBuffer[3].data[2];
	gaoYa1Data[2].data[2] = dataBuffer[3].data[3];
	gaoYa1Data[2].data[3] = dataBuffer[3].data[4];
	gaoYa1Data[2].data[4] = dataBuffer[4].data[1];
	gaoYa1Data[2].data[5] = dataBuffer[4].data[2];
	gaoYa1Data[2].data[6] = dataBuffer[4].data[3];
	gaoYa1Data[2].data[7] = dataBuffer[4].data[4];

	gaoYa1Data[3].data[0] = 0x4Au;
	gaoYa1Data[3].data[1] = dataBuffer[5].data[1];
	gaoYa1Data[3].data[2] = dataBuffer[5].data[2];
	gaoYa1Data[3].data[3] = dataBuffer[5].data[3];
	gaoYa1Data[3].data[4] = dataBuffer[5].data[4];
	gaoYa1Data[3].data[5] = dataBuffer[6].data[1];
	gaoYa1Data[3].data[6] = dataBuffer[6].data[2];
	gaoYa1Data[3].data[7] = dataBuffer[6].data[3];

	gaoYa1Data[4].data[0] = 0x5Au;
	gaoYa1Data[4].data[1] = dataBuffer[6].data[4];
	gaoYa1Data[4].data[2] = dataBuffer[7].data[1];
	gaoYa1Data[4].data[3] = dataBuffer[7].data[2];
	gaoYa1Data[4].data[4] = dataBuffer[7].data[3];
	gaoYa1Data[4].data[5] = dataBuffer[7].data[4];
	gaoYa1Data[4].data[6] = dataBuffer[8].data[1];
	gaoYa1Data[4].data[7] = dataBuffer[8].data[2];

	gaoYa1Data[5].data[0] = 0x6Au;
	gaoYa1Data[5].data[1] = dataBuffer[8].data[3];
	gaoYa1Data[5].data[2] = dataBuffer[8].data[4];
	gaoYa1Data[5].data[3] = dataBuffer[9].data[1];
	gaoYa1Data[5].data[4] = dataBuffer[9].data[2];
	gaoYa1Data[5].data[5] = dataBuffer[9].data[3];
	gaoYa1Data[5].data[6] = dataBuffer[9].data[4];
	gaoYa1Data[5].data[7] = dataBuffer[0].data[6];

	gaoYa1Data[6].data[0] = 0x7Au;
	gaoYa1Data[6].data[1] = dataBuffer[1].data[6];
	gaoYa1Data[6].data[2] = dataBuffer[2].data[6];
	gaoYa1Data[6].data[3] = dataBuffer[3].data[6];
	gaoYa1Data[6].data[4] = dataBuffer[4].data[6];
	gaoYa1Data[6].data[5] = dataBuffer[5].data[6];
	gaoYa1Data[6].data[6] = dataBuffer[6].data[6];
	gaoYa1Data[6].data[7] = dataBuffer[7].data[6];

	gaoYa1Data[7].data[0] = 0x8Au;
	gaoYa1Data[7].data[1] = dataBuffer[8].data[6];
	gaoYa1Data[7].data[2] = dataBuffer[9].data[6];

	gaoYa1Data[7].data[3] = dataBuffer[0].data[7]<<6|
							dataBuffer[1].data[7]<<4|
							dataBuffer[2].data[7]<<2|
							dataBuffer[3].data[7];
	gaoYa1Data[7].data[4] = dataBuffer[4].data[7]<<6|
							dataBuffer[5].data[7]<<4|
							dataBuffer[6].data[7]<<2|
							dataBuffer[7].data[7];

	gaoYa1Data[7].data[5] = dataBuffer[8].data[7]<<6|
							dataBuffer[9].data[7]<<4;
	gaoYa1Data[7].data[6] = 0x00u;
	gaoYa1Data[7].data[7] = 0x00u;

	gaoYa1Data[8].data[0] = 0x9Au;
	gaoYa1Data[8].data[1] = temperature;
	gaoYa1Data[8].data[2] = temperature>>8;
	if(communicationCan1ErrorFlag == 1){
		gaoYa1Data[8].data[3] |= 0x01;
	}else{
		gaoYa1Data[8].data[3] &= 0xfe;
	}
	if((temperature >= 850)&&(temperature <= 1200)){
		gaoYa1Data[8].data[3] |= 0x40;
	}else if(temperature > 1200){
		gaoYa1Data[8].data[3] |= 0x20;
	}else{
		gaoYa1Data[8].data[3] &= 0x9f;
	}
	gaoYa1Data[8].data[4] = dataBuffer[0].data[5]&
							 dataBuffer[1].data[5]&
							 dataBuffer[2].data[5]&
							 dataBuffer[3].data[5]&
							 dataBuffer[4].data[5]&
							 dataBuffer[5].data[5]&
							 dataBuffer[6].data[5]&
							 dataBuffer[7].data[5]&
							 dataBuffer[8].data[5]&
							 dataBuffer[9].data[5];
	gaoYa1Data[8].data[5] = communicationErrorFlag&0xff;
	gaoYa1Data[8].data[6] = communicationErrorFlag>>8;
	gaoYa1Data[8].data[7] = 0x00;

	gaoYa1Data[9].data[0] = 0xAAu;
	gaoYa1Data[9].data[1] = cumulatetime>>24;
	gaoYa1Data[9].data[2] = cumulatetime>>16;
	gaoYa1Data[9].data[3] = cumulatetime>>8;
	gaoYa1Data[9].data[4] = cumulatetime;
	gaoYa1Data[9].data[5] = 0x00;//预留
	gaoYa1Data[9].data[6] = 0x00;//预留

	uint8_t uiCRCNum = 0;
	for(int j = 0;j < UPLOADDATASIZE - 1;j++){
		for(int k = 0;k < 8;k++){
			uiCRCNum += gaoYa1Data[j].data[k];
		}
	}
	for(int j = 0;j < 7;j++){
		uiCRCNum += gaoYa1Data[UPLOADDATASIZE-1].data[j];
	}
	gaoYa1Data[UPLOADDATASIZE-1].data[7] = uiCRCNum;

	for(uint8_t i = 0; i < UPLOADDATASIZE; i ++)
	{
		BSP_CAN1_Transmit(RUNNINGFRAME, gaoYa1Data[i].data);
		HAL_Delay(5);
	}
}

void BSP_CheckModulesComError()
{
	for(int j = 0; j < DATABUFFERSIZE; j ++)
	{
		ErrorID[j].errortimes++;
		if(ErrorID[j].errortimes > JUDEMENTDELAYTIMES)
		{
			receiveFlag &= ~(1<<j);
			ErrorID[j].errortimes = JUDEMENTDELAYTIMES;
		}
		communicationErrorFlag = ~ receiveFlag;
		communicationErrorFlag &= 0x3ff;
	}
}

void Check_ReceiveFlag(uint32_t extId)
{
	uint8_t deviceId = extId & 0xFF;
	receiveFlag |= (1 << (deviceId-1));
	ErrorID[deviceId-1].errortimes = 0;
}

void BSP_UpdateBoxState()
{
	uint8_t check =
			(dataBuffer[0].data[6]&0x3f)|
			(dataBuffer[1].data[6]&0x3f)|
			(dataBuffer[2].data[6]&0x3f)|
			(dataBuffer[3].data[6]&0x3f)|
			(dataBuffer[4].data[6]&0x3f)|
			(dataBuffer[5].data[6]&0x3f)|
			(dataBuffer[6].data[6]&0x3f)|
			(dataBuffer[7].data[6]&0x3f)|
			(dataBuffer[8].data[6]&0x3f)|
			(dataBuffer[9].data[6]&0x1b);
		if(((check & 0x07) != 0x00) || (gaoYa1Data[8].data[3] & 0x20) != 0x00)
		{
			boxState = BSP_FAULT;
		}
		else if(((check & 0x38) != 0x00) || (gaoYa1Data[8].data[3] & 0x40) != 0x00 || ((dataBuffer[9].data[6] & 0x01) == 0x01))
		{
//			boxState = BSP_ALARM;
		}
		else
		{
			boxState = BSP_NORMAL;
		}
}

void Configure_Can1_Filter()
{
	CAN_FilterTypeDef sFilterConfig;
	sFilterConfig.FilterBank = 0;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)CONTROLFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow =   (((uint32_t)CONTROLFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh = ((((uint32_t)SETTINGFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterMaskIdLow =  (((uint32_t)SETTINGFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;

	if(HAL_CAN_ConfigFilter(&hcan1,&sFilterConfig))
	{
		Error_Handler();
	}

	sFilterConfig.FilterBank = 1;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)READFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow =  (((uint32_t)READFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh =  ((((uint32_t)VERSIONFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;;
	sFilterConfig.FilterMaskIdLow =  (((uint32_t)VERSIONFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;

	if(HAL_CAN_ConfigFilter(&hcan1,&sFilterConfig))
	{
		Error_Handler();
	}
}

void Configure_Can2_Filter()
{
	CAN_FilterTypeDef	sFilterConfig;

	sFilterConfig.FilterBank = 14;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)0x0c306301<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow = (((uint32_t)0x0c306301<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh = ((((uint32_t)0x0c306302<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterMaskIdLow = (((uint32_t)0x0c306302<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;

	if(HAL_CAN_ConfigFilter(&hcan2,&sFilterConfig))
	{
		Error_Handler();
	}

	sFilterConfig.FilterBank = 15;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)0x0c306303<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow = (((uint32_t)0x0c306303<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh = ((((uint32_t)0x0c306304<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterMaskIdLow = (((uint32_t)0x0c306304<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;
	if(HAL_CAN_ConfigFilter(&hcan2,&sFilterConfig))
	{
		Error_Handler();
	}

	sFilterConfig.FilterBank = 16;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)0x0c306305<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow = (((uint32_t)0x0c306305<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh = ((((uint32_t)0x0c306306<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterMaskIdLow = (((uint32_t)0x0c306306<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;

	if(HAL_CAN_ConfigFilter(&hcan2,&sFilterConfig))
	{
		Error_Handler();
	}

	sFilterConfig.FilterBank = 17;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)0x0c306307<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow = (((uint32_t)0x0c306307<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh = ((((uint32_t)0x0c306308<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterMaskIdLow = (((uint32_t)0x0c306308<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;

	if(HAL_CAN_ConfigFilter(&hcan2,&sFilterConfig))
	{
		Error_Handler();
	}

	sFilterConfig.FilterBank = 18;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)0x0c306309<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow = (((uint32_t)0x0c306309<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh = ((((uint32_t)0x0c30630a<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterMaskIdLow = (((uint32_t)0x0c30630a<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;

	if(HAL_CAN_ConfigFilter(&hcan2,&sFilterConfig))
	{
		Error_Handler();
	}

	sFilterConfig.FilterBank = 19;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)SETTINGBACKFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow = (((uint32_t)SETTINGBACKFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh = ((((uint32_t)READBACKFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;//¶ÁÈ¡±¨ÎÄID
	sFilterConfig.FilterMaskIdLow =	(((uint32_t)READBACKFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;

	if(HAL_CAN_ConfigFilter(&hcan2,&sFilterConfig))
	{
		Error_Handler();
	}
	sFilterConfig.FilterBank = 20;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = ((((uint32_t)VERSIONCALLBACKFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF0000)>>16;
	sFilterConfig.FilterIdLow =   (((uint32_t)VERSIONCALLBACKFRAME<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
	sFilterConfig.FilterMaskIdHigh = 0x0000;
	sFilterConfig.FilterMaskIdLow =	0x0000;
	sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;

	if(HAL_CAN_ConfigFilter(&hcan2,&sFilterConfig))
	{
		Error_Handler();
	}
}

void BSP_DataInit()
{
	communicationErrorFlag = 0;
	for(uint8_t i = 0; i < DATABUFFERSIZE; i++)
	{
		dataBuffer[i].data[7] = 0x03;
	}
}

#endif


